home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
joystick
/
convert.bas
< prev
next >
Wrap
BASIC Source File
|
1993-08-22
|
1KB
|
40 lines
DefInt A-Z
Dim lpoint As pointapi
Sub convert (x As Integer, y As Integer, thisform As Form)
'***************************************
' Convert joystick coordinates to client window coordinates
' Returns client windows coordinates in type winpoint
'***************************************
'width=8175,height=6105
If need_calibrate Then
deltax = thisform.ScaleWidth / xmax
deltay = thisform.ScaleHeight / ymax
End If
winpoint.x = winxmin + Int(x * deltax)
'Debug.Print "winx="; winpoint.x; "winxmax="; winxmax
winpoint.y = winymin + Int(y * deltay)
'Debug.Print "winy="; winpoint.y; "winymax="; winymax
If Not need_calibrate Then
If winpoint.x > winxmax Then
winpoint.x = winxmax - 10
'x = xmax
End If
If winpoint.x < winxmin Then winpoint.x = winxmin + 1
If winpoint.y < winymin Then winpoint.y = winymin + 1
If winpoint.y > winymax Then winpoint.y = winymax - 10
End If
lpoint.x = winpoint.x / screen.TwipsPerPixelX
lpoint.y = winpoint.y / screen.TwipsPerPixelY
clienttoscreen thisform.hWnd, lpoint' set to screen coords
setcursorpos lpoint.x, lpoint.y' set cursor
End Sub